package com.market.cash.ui.adapter

import androidx.recyclerview.widget.RecyclerView
import com.market.cash.R
import com.market.cash.utils.CashRootImageUtil
import com.market.cash.utils.adapter.CashRootRecyclerViewAdapter
import com.market.cash.utils.adapter.CashRootViewHolderHelper
import org.json.JSONObject

/**
 * CashRoot
 * @Author wwdeng
 * @CreateTime: 2024/10/28 13:45
 * @Annotation：意见反馈 - 图片列表
 */
class CashRootFeedbackImageAdapter(recyclerView: RecyclerView?): CashRootRecyclerViewAdapter<JSONObject>(recyclerView) {

    override fun getItemViewType(position: Int): Int {
        val model = getItem(position)
        if (model.optBoolean("isDefault",true)){
            return R.layout.cash_feedback_add_item
        }
        return R.layout.cash_feedback_image_item
    }
    override fun setItemChildListener(helper: CashRootViewHolderHelper, viewType: Int) {
        helper.setItemChildClickListener(R.id.imgRemove) //删除
        helper.setItemChildClickListener(R.id.addLayout)//选择
    }

    override fun fillData(helper: CashRootViewHolderHelper, position: Int, model: JSONObject) {
        //是否是默认图片
        if (!model.optBoolean("isDefault",true)){
            val ivImage = helper.getImageView(R.id.imgHolder)
            CashRootImageUtil.instance.loadImageUrl(mContext,ivImage,model.optString("imgPath"))
        }
    }
}